function Ydem=demeanDSGEY(Y,funcmod,parvec,solveopt,addsol)
[G,R,C,eu,SDX,Z,structOne,ssvec,structTwo]=feval(funcmod,parvec,solveopt,addsol);
if ~isequal(eu,[1;1])
    lht=[]; 
    return 
end 
if any(C~=0)==1
Ydem=zeros(size(Y)); 
else 
    Ydem=Y; 
    return; 
end 
if isfield(addsol,'tauVec')==false || isempty(addsol.tauVec)==true 
    Ydem=Y-repmat((Z*C)',[size(Y,1) 1]);
elseif isempty(addsol.tauVec)==false 
    Nobs=size(Y,1);
    if length(addsol.tauVec)~=Nobs 
        error('addsol.tauVec must match number of rows in data') 
    end 
    for ii=1:Nobs;
        Ydem(ii,:)=Y(ii,:)-( Z(:,:,addsol.tauVec(ii))*C(:,addsol.tauVec(ii)))';
    end
else
    disp('Cannot Match how should I demean the data')
end